#pragma once

#include "TcpClient.h"
#include "AppCode.h"
#include "Json.hpp"
#pragma comment(lib, "hv.lib")

using json = nlohmann::json;
using namespace hv;

class AppClient 
{
private:
hv::TcpClient* cli;
hv::MessageCallback* msgCallback = NULL;
hv::ConnectionCallback* connectionCallback = NULL;
bool doSend (std::string msg) const;

public:
AppClient();
~AppClient();
void connect(int port);
void onMessage(std::function<void(const AppClient&, json)> const &callback);
void onConnection(std::function<void(const hv::SocketChannelPtr&)> const &callback);
bool send (json msg) const;
};

void test();